package com.kis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.kis.pojo.User;
import com.kis.service.UserService;

@Controller
public class UserInfoController {
	@Autowired
	private UserService userService;

	@RequestMapping(method = RequestMethod.POST, value = "/login")
	public ModelAndView login(User user) {
		boolean canLogin = userService.login(user);
		ModelAndView mv = new ModelAndView();
		if (canLogin) {
			mv.addObject("user",user);
			mv.setViewName("index");
		}else{
			mv.addObject("msg","用户名或密码错误!");
			mv.setViewName("forward:login.jsp");
		}
		return mv;
	}
}
